package com.lsw.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;

/**
 * Created by lsw on 2016/11/29.
 */
public class MyRecordVideo extends ImageView {
    public MyRecordVideo(Context context) {
        super(context);
    }

    public MyRecordVideo(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecordVideo(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                if (touchEvent != null)
                    touchEvent.ACTION_DOWN();
                break;
            case MotionEvent.ACTION_UP:
                if (touchEvent != null)
                    touchEvent.ACTION_UP();
                break;

        }
        return true;
    }

    private TouchEvent touchEvent;

    public void setTouchEvent(TouchEvent touchEvent) {
        this.touchEvent = touchEvent;
    }

    public interface TouchEvent {
        void ACTION_DOWN();

        void ACTION_UP();
    }
}
